package com.myecl.poker.rules;

import java.io.Serializable;

import com.myecl.poker.rules.enums.Rank;
import com.myecl.poker.rules.enums.Suit;


public class Card implements Comparable<Card>, Serializable {
	
	private static final long serialVersionUID = 8004975335388103888L;
		private final Suit suit;		
		private final Rank rank;
		
		public Card(Suit suit, Rank rank) {
			this.suit = suit;
			this.rank = rank;
	}
		
		@Override
		public String toString() {

			return rank.toString() + " of " + getSuit().toString();
		}

		public String toFilename() {
			return suit.toFilename() + rank.toFilename();
		}


		public Suit getSuit() {
			return suit;
		}

		public Rank getRank() {
			return rank;
		}
		
		public int compareSuit(Card card) {
			return (suit.compareTo(card.getSuit()));
		}

		public int compareRank(Card card) {
			return (rank.compareTo(card.getRank()));
		}
		
		@Override
		public int compareTo(Card card) {
			return (rank.compareTo(card.getRank()) * 4) + 
					suit.compareTo(card.getSuit());
		}
		
		
}
